home *** CD-ROM | disk | FTP | other *** search
/ Acorn User 4 / AUCD4.iso / acorn / documents / strongarm / sasupp}003 < prev   
Encoding:
Text File  |  1996-10-04  |  14.4 KB  |  421 lines

  1. This note describes the new or revised SWIs in the StrongARM-aware version
  2. of RISC OS, and gives some guidance on use.
  3.  
  4.  
  5.                           CHANGES TO EXISTING SWIS
  6.                           ========================
  7.                        
  8. OS_MMUControl (page 5a-70)
  9. --------------------------
  10.  
  11.     This SWI has a new reason code, to support platform independent cache
  12.     and/or TLB flushing:
  13.  
  14. OS_MMUControl 1 (SWI &6B)
  15. -------------------------
  16.  
  17.     Cache flush request
  18.     
  19. On entry
  20.     R0 = reason code and flags
  21.            bits 0-7  = 1 (reason code)
  22.            bits 8-28 reserved (must be zero)
  23.            bit 29 set if flush of single entry, else complete flush
  24.            bit 30 set if processor TLBs are to be flushed
  25.            bit 31 set if processor caches are to be flushed
  26.     R1 = logical address, if R0 bit 29 set
  27.  
  28. On exit
  29.     R0,R1 preserved
  30.  
  31. Interrupts
  32.     Interrupt status is not altered
  33.     Fast interrupts are enabled
  34.  
  35. Processor mode
  36.     Processor is in SVC mode
  37.  
  38. Re-entrancy
  39.     SWI is not re-entrant
  40.     
  41. Use
  42.     This call implements platform independent cache and/or TLB flushing.
  43.     
  44.     WARNING: This SWI reason code is only intended for occasional, unavoidable
  45.              requirements for cache/TLB flushing. You should respect the
  46.              performance implications of this SWI reason code, in a similar
  47.              way to SWI OS_SynchroniseCodeAreas.
  48.              
  49.     Currently, bit 29 is ignored, so that only whole flushing of caches
  50.     and/or TLBs are supported. A cache will be cleaned before flushing,
  51.     where the processor supports a write-back cache.
  52.  
  53.     This reason code is not re-entrant. Interrupts are not disabled during
  54.     the flush, so the cache or TLB flush can only be considered to be complete
  55.     with respect to logical addresses that are not currently involved in
  56.     interrupts.
  57.  
  58.  
  59. OS_File 12, 14, 16 and 255 (page 2-40)
  60. --------------------------------------
  61. If R3 bit 31 is set on entry, the file being loaded will be treated as code,
  62. and the relevant area will be synchronised using OS_SynchroniseCodeAreas if
  63. necessary.
  64.  
  65. A filetype for Code (&F95) has been allocated, with the intention that it
  66. be a parallel of Data (&FFD), and when it is loaded a synchronise is
  67. automatically performed. However this functionality has _not_ been implemented
  68. in RISC OS 3.70; you will still need to set bit 31 as described above.
  69.  
  70. Note that the *Load command calls OS_File 255 with bit 31 of R3 set, so no
  71. synchronise is required. This is to aid backwards compatibility; if no
  72. synchronisation is required, then use OS_File 255 directly.
  73.  
  74.  
  75. DMA (page 5a-83)
  76. ----------------
  77. The DMA Manager now marks pages uncacheable for both transfers from device
  78. to memory and transfers from memory to device. This is to ensure StrongARM's
  79. write-back cache is cleaned before the transfer starts.
  80.  
  81.  
  82.  
  83.                              NEW SERVICE CALLS
  84.                              =================
  85.  
  86. Service_UKCompression (Service call &B7)
  87. ----------------------------------------
  88.  
  89.     An application that may need unsqueezing/patching has just been loaded
  90.     
  91. On entry
  92.     R0 = subreason code
  93.            0 -> first pass (unsqueeze)
  94.            1 -> second pass (patch)
  95.            all other codes reserved
  96.     R1 = &B7 (reason code)
  97.     R2 = load address
  98.     R3 = size
  99.     R4 = execute address
  100.     R5 = filename (as passed to FileSwitch, not canonicalised)
  101.  
  102. On exit
  103.     R1 preserved to pass on, or 0 to claim if you know you have performed
  104.     all required unsqueezeing/patching for this pass.
  105.     R3 may be modified to indicate an altered size (eg after unsqueezing)
  106.     R4 may be modified to specify an new execute address
  107.     Other registers preserved
  108.  
  109. Use
  110.     This service call is passed around when an Absolute (&FF8) file is run.
  111.     The sequence of events is as follows.
  112.     
  113.       1) The image is loaded.
  114.       2) If it does not contain an unsqueezed AIF header, then
  115.          Service_UKCompression 0 is issued.
  116.       3) Service_UKCompression 1 is issued.
  117.       4) OS_SynchroniseCodeAreas is called.
  118.     
  119.     Therefore unsqueezers and patchers need not do any synchronisation
  120.     except that necessary for their internal working (they may want to alter
  121.     some code, synchronise, and call it before returning from the service
  122.     call).
  123.     
  124.     Two modules are supplied with RISC OS 3.7 that use this service call:
  125.     
  126.         UnsqueezeAIF will unsqueeze squeezed AIF images on the first pass, and
  127.         squeezed non-AIF images by code modification (so the unsqueeze will
  128.         not occur until after stage 5 above)
  129.     
  130.         AppPatcher will patch squeezed and unsqueezed AIF images containing
  131.         certain common code sequences that are known to fail on StrongARM.
  132.  
  133.     Scanning an application for code sequences is a relatively slow operation.
  134.     Therefore a bit has been allocated in the AIF header to indicate that
  135.     a program is "StrongARM-ready". If bit 31 of the 13th word of the AIF
  136.     header (ie bit 31 of location &8030 in the loaded image) is set, the
  137.     patching stage will be skipped (in RISC OS 3.7 by AppPatcher claiming
  138.     the service call and doing nothing; in a future version of RISC OS
  139.     FileSwitch may not issue the service call). The program will still be
  140.     automatically unsqueezed; it is recommended that you continue to use the
  141.     existing Squeeze utility provided with Acorn C/C++, and rely on the
  142.     operating system to unsqueeze the image for you.
  143.    
  144.    
  145. Service_ModulePreInit (Service call &B9)
  146. ----------------------------------------
  147.  
  148.     A module is about to be initialised
  149.     
  150. On entry
  151.     R0 = module address
  152.     R1 = &B9 (reason code)
  153.     R2 = module length
  154.  
  155. On exit
  156.     R1 preserved to pass on
  157.  
  158. Use
  159.     This service is called just before a module is initialised. When a
  160.     module is *RMLoaded:
  161.     
  162.        1) The module is loaded into memory
  163.        2) The module is unsqueezed if necessary
  164.        3) Service_ModulePreInit is called
  165.        4) OS_SynchroniseCodeAreas is called
  166.     
  167.     This service call is intended to allow run-time patching of modules.
  168.     
  169.     
  170.                                   NEW SWIS
  171.                                   ========
  172.  
  173. OS_PlatformFeatures (SWI &6D)
  174. -----------------------------
  175.  
  176.     Determine various features of the host platform
  177.  
  178. On entry
  179.     R0 = reason code (bits 0-15) and flags (bits 16-31, reason code specific)
  180.     Other registers depend upon the reason code
  181.  
  182. On exit
  183.     Registers depend upon the reason code
  184.  
  185. Interrupts
  186.     Interrupt status is unaltered
  187.     Fast interrupts are enabled
  188.     
  189. Processor mode
  190.     Processor is in SVC mode
  191.  
  192. Re-entrancy
  193.     SWI is re-entrant
  194.  
  195. Use
  196.     This new SWI is used to determine various feaures of the platform that the
  197.     application or module is running on.
  198.  
  199.     The particular action of OS_PlatformFeatures is given by the reason code in
  200.     bits 0-15 of R0 as follows:
  201.     
  202.         R0    Action
  203.         0     Read code features
  204.  
  205.  
  206. OS_PlatformFeatures 0 (SWI &6D)
  207. -------------------------------
  208.  
  209.     Read code features
  210.  
  211. On entry
  212.     R0 = 0 (reason code); all flags are reserved, so bits 16-31 must be clear
  213.  
  214. On exit
  215.     R0 = bit mask of features:
  216.            Bits     Meaning
  217.            0        Must tell OS when code areas change (by calling
  218.                     OS_SynchroniseCodeAreas)
  219.            1        Enabling, then immediately disabling interrupts will _not_
  220.                     give interrupts a chance to occur
  221.            2        Must be in 32 bit mode to read hardware vectors
  222.            3        Storing PC to memory (eg with STR or STM) stores PC+8
  223.                     rather than PC+12
  224.            4        Data aborts occur with 'full early' timing (ie. as defined
  225.                     by ARM architecture 4)
  226.                                 
  227.    If bit 1 of R0 set then                             
  228.      R1 -> routine to call between IRQ enable & disable.
  229.  
  230. Use
  231.     This call determines features of the host processor's instruction set.
  232.     
  233.     Platforms running ARM 6 or 7 cores will return with R0 bits 0-4 clear;
  234.     platforms running StrongARM will return with bits 0-4 set. For
  235.     compatibility with older versions of RISC OS, you should call this SWI in
  236.     the X form; if V is set on return and the error is 'SWI not known', then
  237.     this can be taken as equivalent to a return with R0 bits 0-4 clear. Note
  238.     that the easiest way to deal with the PC+8/PC+12 issue across all
  239.     platforms is to make sure that the code is valid in either case (typically
  240.     with judicious use of NOPs).
  241.     
  242.     The routine pointed to by R1 is suitable for calling from any 26-bit mode;
  243.     it preserves all flags and registers, and is reentrant. It should be
  244.     called as follows
  245.     
  246.         LDR    R0, irqroutine   ; Load address previously stored in workspace
  247.         MOV    R14, PC          ; Get return address of PC+8
  248.         MOV    PC, R0           ; Call routine
  249.         ...                     ; Code returns here
  250.  
  251.  
  252. OS_SynchroniseCodeAreas (SWI &6E)
  253. ---------------------------------
  254.  
  255.     Inform the OS that code has been altered
  256.  
  257. On entry
  258.     R0 = flags
  259.            bit 0 clear  Entire address space to be synchronised.
  260.            bit 0 set    Address range to be synchronised.
  261.            bits 1-31    Reserved
  262.  
  263.     If R0 bit 0 is set then:
  264.         R1 = low address of range (word aligned)
  265.         R2 = high address (word aligned, _inclusive_)
  266.  
  267. On exit
  268.     R0-R2 preserved
  269.  
  270. Interrupts
  271.     Interrupt status is not altered
  272.     Fast interrupts are enabled
  273.  
  274. Processor mode
  275.     Processor is in SVC mode
  276.  
  277. Re-entrancy
  278.     SWI is not re-entrant
  279.  
  280. Use
  281.     This new SWI informs the OS that code has been newly generated or
  282.     modified in memory, before any attempt is made to execute the code.
  283.  
  284.     WARNING: This SWI is only intended for synchronisation with unavoidable
  285.              use of dynamic code, because of the potential for large
  286.              performance penalties. There is no longer any justification in
  287.              RISC OS applications for frequent code modification. This call
  288.              must never be used in an interrupt routine. Examples of
  289.              reasonable use include one-off loading, relocation etc. of
  290.              subsidiary code or libraries.
  291.      
  292.     When using this SWI, you should use the ranged variant wherever possible,
  293.     in order to minimise the performance penalty.
  294.     
  295.     The call may take a long time to return (up to around 0.5ms), so it should
  296.     not be called with interrupts disabled.
  297.  
  298.     For compatibility with older versions of RISC OS, you should either have
  299.     determined (with OS_PlatformFeatures) that this SWI should not be called,
  300.     or always call this SWI in the X form, and ignore any error returned. On
  301.     platforms that do not require code synchronisation (as indicated by
  302.     OS_PlatformFeatures 0), OS_SynchroniseCodeAreas will do nothing.
  303.  
  304.     Note that standard loading of applications or modules (and the standard C
  305.     overlay system) are automatically handled by the OS, and do not require
  306.     synchronisation. This may be defeated by custom squeezing, failure to use
  307.     a standard AIF header for applications, and so on.
  308.  
  309.  
  310. OS_CallASWI (SWI &6F)
  311. ---------------------
  312.  
  313.     Call a run-time determined SWI
  314.  
  315. On entry
  316.     R0-R9 as required for target SWI
  317.     R10 = target SWI number
  318.  
  319. On exit
  320.     R0-R9 as defined by target SWI
  321.     R10 preserved
  322.  
  323. Interrupt status
  324.    As defined by target SWI
  325.  
  326. Processor mode
  327.    As defined by target SWI
  328.  
  329. Re-entrancy
  330.    As defined by target SWI
  331.  
  332. Use
  333.     This new SWI allows a target SWI number to be determined at run time, and
  334.     passed in a register. This removes the need for a common idiom of
  335.     dynamic code, in language library SWI veneers for example. In an APCS-R
  336.     library, OS_CallASWIR12 may be more appropriate (see below).
  337.  
  338.     Note that OS_CallASWI is merely an alias for calling the target SWI.
  339.     It has no entry/exit conditions of its own, except for the special
  340.     use of R10. To call a target SWI with X bit set, us the X form of
  341.     the SWI number in R10; there is no distinction between OS_CallASWI
  342.     and XOS_CallASWI.
  343.  
  344.     You cannot call OS_CallASWI or OS_CallASWIR12 via OS_CallASWI, since there
  345.     is no defined final target SWI in this case.
  346.  
  347.     You cannot usefully call OS_BreakPt or OS_CallAVector using OS_CallASWI,
  348.     as OS_CallASWI will corrupt the processor flags before entering the
  349.     target SWI.
  350.     
  351.     For future compatibility, you should always use this SWI in preference
  352.     to any local construction for calling a SWI by number. For compatibility
  353.     with older versions of RISC OS, a new CallASWI module will be made available
  354.     (see below).
  355.     
  356.     Note that this SWI calling mechanism is almost certainly faster than
  357.     any other alternative implementation, including the original _kernel_swi
  358.     and _swix code contained in older versions of the SharedCLibrary. The
  359.     new SharedCLibrary now simply uses OS_CallASWIR12 for _kernel_swi and
  360.     _swix.
  361.     
  362.     OS_CallASWI cannot be called from BASIC as BASIC only passes registers
  363.     R0-R7 via its SYS instruction. It would not be useful anyway.
  364.  
  365.  
  366. OS_AMBControl (SWI &70)
  367. -----------------------
  368.  
  369.     This SWI is for system use only; you must not use it in your own code.
  370.  
  371.  
  372. OS_CallASWIR12 (SWI &71)
  373. ------------------------
  374.  
  375.     Call a run-time determined SWI
  376.  
  377. On entry
  378.     R0-R9 as required for target SWI
  379.     R12 = target SWI number
  380.  
  381. On exit
  382.     R0-R9 as defined by target SWI
  383.     R12 preserved
  384.  
  385. Interrupt status
  386.    As defined by target SWI
  387.  
  388. Processor mode
  389.    As defined by target SWI
  390.  
  391. Re-entrancy
  392.    As defined by target SWI
  393.  
  394. Use
  395.     This call is identical to OS_CallASWI, except that it uses R12 to specify
  396.     the target SWI. This may be more convenient in some environments. In
  397.     particular under APCS-R, R10 is the stack limit pointer, which must be
  398.     preserved at all times; if a SWI called using OS_CallASWI were to abort
  399.     or generate an error the run-time library would usually examine R10
  400.     and decide that it had no stack to handle the abort or error. Therefore
  401.     APCS-R libraries must use OS_CallASWIR12 (R12 being a scratch register
  402.     under APCS-R).
  403.  
  404.  
  405.                       THE CALLASWI MODULE
  406.                       ===================
  407.  
  408. The CallASWI module provides support under RISC OS 3.1, 3.5 and 3.6 for
  409. the following SWIs:
  410.  
  411.               OS_CallASWI
  412.               OS_CallASWIR12
  413.               OS_PlatformFeatures
  414.               OS_SynchroniseCodeAreas
  415.  
  416. This will enable application programmers and library writers to use the
  417. new calls freely without any worries about backwards compatibility. There
  418. is no performance penalty for the use of these SWIs via the CallASWI
  419. module. One slight caveat is that older machines will not know the
  420. _names_ of these SWIs; they would have to be called by number from BASIC.
  421.